package es.uned.ii.si3;

import javax.servlet.http.HttpServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.apache.log4j.xml.DOMConfigurator;

public class Inicializador extends HttpServlet {

    public void init(ServletConfig config) throws ServletException {

    	super.init();
        
        //DOMConfigurator.configure(Classpath.getClassRoot(this.getClass().getName()) + "../conf/log4j-si3.xml");
        //DOMConfigurator.configure(Inicializador.class.getClassLoader().getResource("../conf/log4j-si3.xml"));
        
        String log4jLocation = config.getInitParameter("log4j-properties-location");

        if (log4jLocation != null) {
	        ServletContext sc = config.getServletContext();
	        String webAppPath = sc.getRealPath("/");
	        DOMConfigurator.configure(webAppPath + log4jLocation);
        }
    }
}
